/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package services;


import Entitys.UsoMedicamento;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author MAURO
 */
public class UsoMedicamentoServices {
    EntityManagerFactory emf= Persistence.createEntityManagerFactory("DrugStoreProPU");
         EntityManager em=emf.createEntityManager();
         
         public void create (UsoMedicamento u){
          em.getTransaction().begin();
          em.persist(u);
          em.getTransaction().commit();
          em.close();
         }
    
         public void delete (Integer   p){
          em.getTransaction().begin();
          UsoMedicamento p1=em.find(UsoMedicamento.class, p);
          if(p1!= null)
          em.remove(p1);
          em.getTransaction().commit();
          em.close();
         }
}
